﻿{% extends "base.html" %}

{% block scripts %}
{% endblock %}

{% block content %}
    <div class="company_block">
					<h1>{{ company.name }}</h1>
				
					<div class="info_panel">
						<img class="company_pic"
                             {% if company.logo %}
                                src="{{ company.logo.url }}"
                                {% if company.logo.width > company.logo.height %} width="135" {% else %} height="135" {% endif %}
                             {% else %}
                                src="/media/images/img_no.gif" width="135" height="135"
                             {% endif %}
                         />
                        <ul class="profile_options">
                        {% if request.user == company.owner %}
							<li class="option_item"><a href="/edit_company/{{ company.id }}/">Редактировать компанию</a></li>
							<li class="option_item"><a href="/edit_orders/{{ company.id }}/">Редактировать заказы</a></li>
                            <li class="option_item"><a href="/add_partner/{{ company.id }}/">Добавить партнера</a></li>
                            <li class="option_item"><a href="/create_offer/{{ company.id }}/">Добавить предложение</a></li>
                            <li class="option_item"><a href="/add_good/">Добавить товар</a></li>
                        {% endif %}
                        {% if request.user in company.users.all %}
                            <li class="option_item"><a href="/delete_from_company/{{ company.id }}/">Удалить из избранного</a></li>
                        {% else %}
                            <li class="option_item"><a href="/add_to_companies/{{ company.id }}/">Добавить в избранные</a></li>
                        {% endif %}

                        </ul>


						<!--
						<div class="map_block">
							<div class="block_h"><span class="h">Карта</span> <a class="link" href="#">Увеличить</a></div>
							<img src="i/map_1.jpg" width="135" height="100">
						</div>
						-->
					</div>
				
					<div class="company_base">
					
						<div class="base_info_block">
							<p class="company_description">
                                 {% for category in company.categories.all %}
                                    {{ category.name }} {% if not forloop.last %},{% endif %}
                                {% endfor %}
							</p>
							<dl>
                                {% if company.fiz_address %}
                                    <dt>Адрес:</dt>
									<dd>{{ company.fiz_address }}</dd>
                                {% endif %}

								{% if company.phone %}
								    <dt>Телефон:</dt>
									<dd>{{ company.phone }}</dd>
                                {% endif %}

                                {% if company.worktime %}
                                    <dt>Время работы:</dt>
								    <dd>{{ company.worktime }}</dd>
                                {% endif %}

								{% if company.website %}
                                    <dt>Сайт:</dt>
									<dd><a href="http://{{ company.website }}">{{ company.website }}</a></dd>
                                {% endif %}

                                {% if company.skype %}
                                    <dt>Skype:</dt>
									<dd>{{ company.skype }}</dd>
                                {% endif %}

                                {% if company.icq %}
                                    <dt>ICQ:</dt>
									<dd>{{ company.icq }}</dd>
                                {% endif %}

                                {% if company.email %}
                                    <dt>E-mail:</dt>
									<dd>{{ company.email }}</dd>
                                {% endif %}

                                <dt>Администратор:</dt>
									<dd><a href="/profile/{{ company.owner.id }}/">{{ company.owner.user_info.first_name }} {{ company.owner.user_info.last_name }}</a></dd>

                                {% if company.activities.count > 0 %}
                                <dt>Деятельность:</dt>
									<dd>
                                    {% for activity in company.activities.all %}
                                        {{ activity.name }} {% if not forloop.last %},{% endif %}
                                    {% endfor %}
                                    </dd>
                                {% endif %}

							</dl>
							<p>{{ company.description }}</p>
						</div>
						
					</div>
				
					<!--
                    <div class="base_block ">
						<h2 class="block_header">Обсуждения</h2>
					
						<ul class="block_content debate_list">
							<li class="item">
								<h3 class="cat"><a href="#">Информационная безопасность</a> <span class="icon"></span></h3>
								<div class="author"><a href="#">Иван Иванов</a> <span class="icon"></span></div>
								<div class="mess_num">14 сообщений</div>
								<div class="date">22 июл в 22:31</div>
							</li>
							<li class="item">
								<h3 class="cat"><a href="#">Информационная безопасность</a> <span class="icon"></span></h3>
								<div class="author"><a href="#">Иван Иванов</a> <span class="icon"></span></div>
								<div class="mess_num">14 сообщений</div>
								<div class="date">22 июл в 22:31</div>
							</li>
							<li class="item">
								<h3 class="cat"><a href="#">Информационная безопасность</a> <span class="icon"></span></h3>
								<div class="author"><a href="#">Иван Иванов</a> <span class="icon"></span></div>
								<div class="mess_num">14 сообщений</div>
								<div class="date">22 июл в 22:31</div>
							</li>
						</ul>
						
						<a class="block_more" href="#">все обсуждения</a>
					</div>
					-->
				
				
					<div class="base_block">
						<h2 class="block_header">Витрина</h2>
					
						<ul class="block_content user_list showcase_small_list">
							{% for good in company.goods.all %}
                                {% if forloop.counter0 < 16 %}
                                <li class="item">
                                    <!--<a class="showcase" href="/showcase/{{ company.id }}/">-->
                                    <a class="showcase" title="{{ good.name }} {{ good.price }} p" href="{% if good.image %}{{ good.image.url }}{% else %}/media/images/img_no.gif{% endif %}">
                                         <img class="pic"
                                             {% if good.image %}
                                                src="{{ good.image.url }}"
                                                {% if good.image.width > good.image.height %} width="47" {% else %} height="47" {% endif %}
                                             {% else %}
                                                src="/media/images/img_no.gif" width="47" height="47"
                                             {% endif %}
                                         />
                                    </a>
                                </li>
                                {% endif %}
                            {% endfor %}
						</ul>
						
						<a class="block_more" href="/showcase/{{ company.id }}/">все товары</a>
					</div>
					
					<div class="base_block">
						<h2 class="block_header">Клиенты</h2>
					
						<ul class="block_content user_list">
					    {% for client in company.users.all %}
                            {% if forloop.counter0 < 16 %}
                            <li class="item">
                            <a href="/profile/{{ client.id }}/">
                                 <img class="pic"
                                 {% if client.user_info.avatar %}
                                    src="{{ client.user_info.avatar.url }}"
                                    {% if client.user_info.avatar.width > client.user_info.avatar.height %}
                                    width="47"
                                    {% else %}
                                    height="47"
                                    {% endif %}
                                 {% else %}
                                    src="/media/images/nophoto.jpg/"
                                    width="47" height="47"
                                 {% endif %}
                                 />{{ client.user_info.first_name }} {{ client.user_info.last_name }}
                            </a>
                            </li>
                            {% endif %}

                            {% endfor %}
						</ul>
						
						<a class="block_more" href="/all_clients/{{ company.id }}/">все клиенты</a>
					</div>
				
					<div class="base_block">
						<h2 class="block_header">Партнеры</h2>

						<ul class="block_content user_list user_partners_list">
                        {% for partner in company.partners.all %}
                          {% if forloop.counter0 < 16 %}
                          <li class="item">
                                <a href="/company/{{ partner.id }}/">
                                     <img class="pic"
                                     {% if partner.logo %}
                                        src="{{ partner.logo.url }}"
                                        {% if partner.logo.width > partner.logo.height %}
                                        width="47"
                                        {% else %}
                                        height="47"
                                        {% endif %}
                                     {% else %}
                                        src="/media/images/img_no.gif/"
                                        width="47" height="47"
                                     {% endif %}
                                     />
                                    {{ partner.name }}
                                </a>
							</li>
                            {% endif %}
                        {% endfor %}
						</ul>

						<a class="block_more" href="/all_partners/{{ company.id }}/">все партнеры</a>
					</div>
					
				
					<div class="base_block">
						<h2 class="block_header">Предложения </h2>
					
						<ul class="block_content partners_list">
                            {% for offer in company.offers.all %}
                                {% if forloop.counter0 < 10 %}
                                <li class="item">
                                    <div class="item_base">
                                         <img class="pic"
                                         {% if company.logo %}
                                            src="{{ company.logo.url }}"
                                            {% if company.logo.width > company.logo.height %}
                                            width="47"
                                            {% else %}
                                            height="47"
                                            {% endif %}
                                         {% else %}
                                            src="/media/images/img_no.gif/"
                                            width="47" height="47"
                                         {% endif %}
                                         />
                                        <span class="text">{{ offer.text|linebreaksbr }}</span>
                                    </div>
                                    <ul class="options">
                                        <li class="option_item"><a href="/edit_offer/{{ offer.id }}/">Редактировать</a></li>
                                        <li class="option_item"><a href="/delete_offer/{{ offer.id }}/">Удалить</a></li>
                                    </ul>
                                </li>
                                {% endif %}
                            {% endfor %}

						</ul>
						
						<a class="block_more" href="/all_offers/{{ company.id }}/"> все предложения</a>
					</div>
    </div>
	            
{% endblock %}